<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let obj = {
        a: {
          b: {
            c: 666
          },
          e: {
            f: 777
          }
        }
      }

      var str = 'a.e.f'
      const getData = () => {
        // [reduce](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
        var newArr = str.split('.').reduce((o, s) => {
          //  console.log('obj: ', obj)
          //  console.log('o: ', o)
          //  console.log('s: ', s)
          return o[s]
        }, obj)
        return newArr
      }
      console.log(getData())
    </script>
  </body>
</html>
